/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package movie.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

/**
 *
 * @author admin
 */
@Entity
@Table(name = "favourite")
@NamedQueries({
	@NamedQuery(name = "Favourite.findAll", query = "SELECT f FROM Favourite f")})
public class Favourite implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_favourite")
	private Integer idFavourite;
	@Basic(optional = false)
    @NotNull
    @Column(name = "date_created")
    @Temporal(TemporalType.TIMESTAMP)
	private Date dateCreated;
	@JoinColumn(name = "id_user_access", referencedColumnName = "id_user_access")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
	private UserAccess idUserAccess;
	@JoinColumn(name = "id_film", referencedColumnName = "id_film")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
	private Film idFilm;

	public Favourite() {
	}

	public Favourite(Integer idFavourite) {
		this.idFavourite = idFavourite;
	}

	public Favourite(Integer idFavourite, Date dateCreated) {
		this.idFavourite = idFavourite;
		this.dateCreated = dateCreated;
	}

	public Integer getIdFavourite() {
		return idFavourite;
	}

	public void setIdFavourite(Integer idFavourite) {
		this.idFavourite = idFavourite;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public UserAccess getIdUserAccess() {
		return idUserAccess;
	}

	public void setIdUserAccess(UserAccess idUserAccess) {
		this.idUserAccess = idUserAccess;
	}

	public Film getIdFilm() {
		return idFilm;
	}

	public void setIdFilm(Film idFilm) {
		this.idFilm = idFilm;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (idFavourite != null ? idFavourite.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof Favourite)) {
			return false;
		}
		Favourite other = (Favourite) object;
		if ((this.idFavourite == null && other.idFavourite != null) || (this.idFavourite != null && !this.idFavourite.equals(other.idFavourite))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "movie.entity.Favourite[ idFavourite=" + idFavourite + " ]";
	}
	
}
